require 'fileutils'

rails_app = ARGV[ARGV.index("-r") + 1]
app = ARGV[ARGV.index("-a") + 1]
name = ARGV[ARGV.index("-n") + 1]


["mac", "linux", "windows"].each do |platform|
  package_dir = platform == "mac" ? "package.app" : "package"
  app_dir = platform == "mac" ? "#{name}.app" : name
  FileUtils.mkdir_p "builds/#{name}/#{platform}"
  FileUtils.cp_r "platforms/#{platform}/#{package_dir}/.", "builds/#{name}/#{platform}/#{app_dir}"
  app_dir += "/Contents" if platform == "mac"
  FileUtils.cp_r "#{app}/.", "builds/#{name}/#{platform}/#{app_dir}/Resources"
  FileUtils.cp_r rails_app, "builds/#{name}/#{platform}/#{app_dir}/Resources/application"
end